<?php

namespace app\common\model;

use app\common\model\BaseModel as BaseModel;

/**
 * Class PromotionGroup
 * @package app\common\model
 * @property int $id
 * @property string $groupName
 * @property string $channel
 * @property string $bdToken
 * @property string $bdNewType
 * @property string $membersStr
 * @property int $isDel
 * @property string $promotionPlatform
 * @property int $updated
 * @property int $created
 * @link https://www.kancloud.cn/manual/thinkphp6_0/1037579
 * @link https://www.kancloud.cn/manual/think-orm/1257998
 * @link https://www.kancloud.cn/thinkphp/master-database-and-model/265551
 */
class PromotionGroup extends BaseModel
{
    protected $name = 'PromotionGroup';

    public function getDeductionProportionAttr($value, $data)
    {
        return (float)bcmul($value, 100, 2);
    }

    public function setDeductionProportionAttr($value, $data)
    {
        return bcdiv($value, 100, 4);
    }

    public function getDeductionProportionOriginAttr($value, $data)
    {
        return $data['deductionProportion'];
    }


    /**
     * 1对1
     * @return \think\model\relation\HasOne
     */
    //    public function one(){
    //        return $this->hasOne( Test1::class, 'Test1表中的键', 'PromotionGroup表中的键');
    //    }

    /**
     * 1对多
     * @return \think\model\relation\HasMany
     */
    //    public function many(){
    //        return $this->hasMany( Test1::class, 'Test1表中的键', 'PromotionGroup表中的键');
    //    }

    /**
     * 多对多
     * @return \think\model\relation\BelongsToMany
     */
    //    public function belongs(){
    //        return $this->belongsToMany( Test1::class, '中间表', '中间表中Test1的键', '中间表中PromotionGroup的键');
    //    }
}
